﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Chapter04
{
    using System.IO;
    using Ch04Width = Chapter04.Widget;

    partial class Program
    {
        internal static void Begin(Action action, bool active = false)
        {
            if (active)
            {
                Console.WriteLine("开始演示：");
                action();
                Console.WriteLine("演示完毕：");
                Console.ReadLine();
            }
        }

        internal static void C0201()
        {
            object o = new Employee();
            Employee e = (Employee)o;
        }

        private class Employee : Object 
        {
            internal int GetYeartEmployed() { return 0; }

            internal virtual string GenProgressReport() { return null; }

            internal static Employee Lookup(string name) { return null; }
        }

        internal static void C0202()
        {
            Manager m = new Manager();
            PromoteEmployee(m);
            DateTime newYears = new DateTime(2010, 1, 1);
            PromoteEmployee(newYears);
        }

        private class Manager : Employee 
        {
            internal override string GenProgressReport() { return base.GenProgressReport(); }
        }

        private static void PromoteEmployee(object o)
        {
            Employee e = (Employee)o;
        }

        internal static void C0203()
        {
            object o = new object();
            Boolean b1 = (o is object);
            Boolean b2 = (o is Employee);
            if (o is Employee)
            {
                Employee e = (Employee)o;
            }
            {
                Employee e = o as Employee;
                if (e != null)
                {
                    e.ToString();
                }
            }
        }

        internal static void C0301()
        {
            FileStream fs = new FileStream("", FileMode.Open);
            StringBuilder sb = new StringBuilder();
        }

        internal static void C0302()
        {
            Widget w1 = new Widget();
            Chapter04.Widget w2 = new Chapter04.Widget();
            Ch04Width w3 = new Ch04Width();
        }

        private class Widget { }

        internal static void C04()
        {
            M1();
        }

        private static void M1()
        {
            string name = "Joe";
            M2(name);
        }

        private static void M2(string s)
        {
            int length = s.Length;
            int tally = 0;
            Console.WriteLine(tally);
        }

        private static void M3()
        {
            Employee e;
            int year;
            e = new Manager();
            e = Employee.Lookup("Joe");
            year = e.GetYeartEmployed();
            e.GenProgressReport();
        }
    }

    internal class Widget { }

    namespace CompanyName
    {
        internal sealed class A { }

        namespace X
        {
            internal sealed class B { }
        }
    }
}
